<template>
  <img :src="imgUrl" height="320" width="480" v-show="Visible" />
</template>

<script>
  import axios from 'axios'
  export default {
    name: "Getimg",
    props: ['pictname'],
    data(){
      return{
        imgUrl: '',
        // url1: 'http://localhost',
        url1: 'http://192.168.11.129',
        port: ':8008',
        pictna: '',
        Visible: false,
      }
    },
    methods: {
      nowGitimg(){
        // console.log(this.pictna);
        let url = this.url1 + this.port + '/Pictures/' + this.pictna;
        axios.get(url,{responseType: 'arraybuffer'}).then(data=>{
          console.log(data);
          this.imgUrl = 'data:image/png;base64,' + btoa(new Uint8Array(data.data).reduce((data, byte) => data + String.fromCharCode(byte), ''));

        }).catch(function(err){
          error(err)
        });
      },



      // formerGitimg(){
      //   let url = 'http://localhost:8008/Pictures/formerimg';
      //   axios.get(url,{responseType: 'arraybuffer'}).then(data=>{
      //     console.log(data);
      //     this.imgUrl = 'data:image/png;base64,' + btoa(new Uint8Array(data.data).reduce((data, byte) => data + String.fromCharCode(byte), ''));
      //
      //   }).catch(function(err){
      //     error(err)
      //   });
      // }
    },

    watch:{
      pictname:function(newData,oldData){
        console.log(newData)  //newData就是orderData
        this.pictna = newData;
        this.nowGitimg();
      }
    },


    // mounted() {
    //   this.Gitimg();
    // }
  }
</script>

<style scoped>

</style>
